typeAsString

fun Context.typeAsString(@StringOrStringRes stringOrStringRes: Any): String

Parses the received data type stringOrStringRes and always returns a String.

  • If the data type is String, it returns it as is, without processing.

  • If the data type is char, it returns it as a String.

  • If the data type is an integer, it is assumed to be a resource ID, so the String is obtained from resources and returned. If the resource does not exist, it throws an exception.

  • For any another data type, it throws an exception, since the data type cannot be parse directly as a String.